package com.zhou.jianzhi.controller.web;/**
 * @project jianzhi-server-master
 * @description
 * @author 黄嘉杰
 * @date 2025/1/23 12:19:27
 * @version 1.0
 */

import com.zhou.jianzhi.common.AjaxResult;
import com.zhou.jianzhi.entity.dto.EvaluationDTO;
import com.zhou.jianzhi.entity.po.Evaluation;
import com.zhou.jianzhi.entity.po.ForumPost;
import com.zhou.jianzhi.mapper.RecruitUnitMapper;
import com.zhou.jianzhi.service.EvaluationService;
import com.zhou.jianzhi.service.ForumPostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @description: TODO
 * @author 黄嘉杰
 * @date 2025/1/23 12:19
 * @version 1.0
 */
@RestController
@RequestMapping("/message")
public class MessageController {
    @Autowired
    private EvaluationService evaluationService;
    @Autowired
    private RecruitUnitMapper mapper;

    @GetMapping("/listByRecruitUnitId")
    public AjaxResult listByRecruitUnitId() {
        return AjaxResult.success(mapper.selectList(null));
    }
    /**
     * 获取列表
     * @param type 1是用户给商家评价，0是商家给用户评价
     * @param page 页码
     * @param size 每页数量
     */
    @GetMapping("/list")
    public AjaxResult getList(
            @RequestParam(required = false) String type,
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10") Integer size
    ) {
        return AjaxResult.success(evaluationService.getList(type, page, size));
    }

    /**
     * 发布新评论
     */
    @PostMapping("/add")
    public AjaxResult add(@RequestBody Evaluation evaluation) {
        evaluationService.add(evaluation);
        return AjaxResult.success();
    }

    /**
     * 修改帖子
     */
    @PostMapping("/edit")
    public AjaxResult editPost(@RequestBody EvaluationDTO evaluation) {
        evaluationService.edit(evaluation);
        return AjaxResult.success();
    }

    /**
     * 删除帖子
     */
    @DeleteMapping("/{id}")
    public AjaxResult deletePost(@PathVariable Long id) {
        evaluationService.delete(id);
        return AjaxResult.success();
    }

//    /**
//     * 获取帖子详情
//     */
//    @GetMapping("/{id}")
//    public AjaxResult getPostDetail(@PathVariable Long id) {
//        return AjaxResult.success(evaluationService.getDetail(id));
//    }
}
